#coding=utf-8
import cv2
import os
# 要提取视频的文件名，隐藏后缀
sourceFileName = '3'
# 在这里把后缀接上
video_path = os.path.join('/home/xiehm/', sourceFileName + '.mp4')
times = 200
# 提取视频的频率，每１帧提取一个
frameFrequency = 5
# 输出图片到当前目录vedio文件夹下
outPutDirName = 'vedio2//' + sourceFileName + '/'
if not os.path.exists(outPutDirName):
    # 如果文件目录不存在则创建目录
    os.makedirs(outPutDirName)
camera = cv2.VideoCapture("/home/xiehm/3.mp4")
while True:
    times += 1
    res, image = camera.read()
    if not res:
        print('not res , not image')
        break
    if times % frameFrequency == 0:
        cv2.imwrite(outPutDirName +'cjy' +str(times) + '.jpg', image)
        print(outPutDirName+'cjy1' + str(times) + '.jpg')
print('图片提取结束')
camera.release()
